﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace DAL
{
    public class D_CustomType : IDAL.ICustomType
    {
        WishDayEntities _e;
        public D_CustomType()
        {
            _e = new WishDayEntities();
        }
        public void Add(CustomType obj)
        {
            _e.CustomType.Add(obj);
            _e.SaveChanges();
        }

        public void Delete(int id)
        {
            var data = _e.CustomType.Find(id);
            _e.CustomType.Remove(data);
            _e.SaveChanges();
        }

        public CustomType FindById(int id)
        {
            return _e.CustomType.Find(id);
        }

        public List<CustomType> GetAll()
        {
            return _e.CustomType.ToList();
        }

        public void Update(int id, CustomType obj)
        {
            var data = _e.CustomType.Find(id);
            data.CName = obj.CName;
            data.CPower = obj.CPower;
            data.IsShow = obj.IsShow;
            _e.SaveChanges();
        }
    }
}
